<!doctype html>
<html>
<head>
    <meta http-equiv="content-type" content="text/html; charset=UTF-8" />
    <title>职业技能信息</title>
    <script src="/webjars/miniui/boot.js" type="text/javascript"></script>
    <link href="/static/css/resource.css" rel="stylesheet" type="text/css" />
    <script src="/static/js/common/common.js" type="text/javascript"></script>
    <link href="/webjars/miniui/css/demo.css" rel="stylesheet" type="text/css" />
    <link href="/static/css/default.css" rel="stylesheet" type="text/css" />
    <style>
        .discell {
            text-align:right;
            width:160px;
        }
        .input {
            width:250px;
        }
        tr {
            display:table-row;
        }
        table {
            width:100%;
            border-collapse:separate;
            border-spacing:6px;
            margin:0 6% 0 0;
        }
    </style>
</head>
<body>
<div class="mini-fit" id="en" style="padding-top:20px;margin-bottom:45px;">
    <form id="form1" method="post">
        <input name="priNum" id="priNum" class="mini-hidden" value="${priNum!''}" />
        <input name="id" id="id" class="mini-hidden" value="${id!''}" />
        <br>
        <table align="center">
            <tr>
                <td class="discell"><font color="#dc143c">*</font>教育类型:</td>
                <td>
                    <input name="type" id="type" class="mini-combobox" required="true" style="width:280px"
                           textField="text" valueField="id" emptyText="请选择..." onvaluechanged="onZyjnChanged"
                           url="/search/code/native?1=1&codeType=4_1&pcodeId=0" showNullItem='true' value="${type!''}"
                    />
                </td>
            </tr>
            <tr id="zyid" style="display: none;">
                <td class="discell"><font color="#dc143c">*</font>职业技能分类:</td>
                <td>
                    <input name="parentZyjn" id="parentZy" class="mini-combobox" required="true" style="width:280px"
                           textField="text" valueField="id" emptyText="请选择..." onvaluechanged="onZyjnChanged1"
                           url="/search/code/native?1=1&codeType=4_1&pcodeId=-1" showNullItem='true'
                           value="${parentZyjn!''}"
                    />
                </td>
            </tr>
            <tr>
                <td class="discell"><font color="#dc143c">*</font>职业技能:</td>
                <td>
                    <input name="zyjn" id="zyjn" class="mini-combobox" required="true"
                           textField="text" valueField="id" emptyText="请选择..." style="width:280px"
                           url="/search/code/zyjn?1=1&codeType=4_1&pcodeId=${parentZyjn!''}" value="${zyjn!''}"
                    />
                </td>
            </tr>
            <tr>

            </tr>
            <tr>
                <td class="discell">是否获得证书:</td>
                <td class="input">
                    <input name="isAccept" id="jineng" class="mini-radiobuttonlist" style="width:280px"
                           data="[{ id: '01', name: '是' },{ id: '02', name: '否' }]" value="${isAccept!'02'}"
                           textField="name" valueField="id" required="true" onvaluechanged="valueChangeDo()" />
                </td>
            </tr>
            <tr>
                <td class="discell"><font id="certstyle" style="display:none" color="#dc143c">*</font>证书名称:</td>
                <td class="input">
                    <input class="mini-textbox" type="text" id="certName" name="certName" value="${certName!''}"
                           emptyText="请输入证书名称..." style="width:280px" readonly="true" />
                </td>
            </tr>
        </table>
    </form>
</div>
<div style="width:100%;position:absolute;bottom:0;line-height: 45px;border-top: 1px solid #dfdfdf;text-align: center">
    <a class="mini-button" iconCls="fa-save" plain="true" style="font-size: 15px" onclick="saveData()">保存</a>
    <a class="mini-button" iconCls="fa-close" plain="true" style="font-size: 15px" onclick="onCancel()">关闭</a>
</div>
<script type="text/javascript">
    mini.parse();
    var form = new mini.Form("form1");
    var certName = mini.get("certName");
    var jineng = mini.get("jineng");
    var type = mini.get("type");
    var typeval = type.getValue();
    //当教育类型为职业技术教育时，页面上来就展示 职业技能分类 标签
    if ("-1" == typeval) {
        $("#zyid").css("display", "table-row");
    }

    //是否获取证书:02:否 01:是
    if ('01' == jineng.getValue()) {
        certName.readOnly = false;
    } else {
        certName.readOnly = true;
    }

    // 保存减刑假释信息数据
    function saveData() {
        form.validate();
        if (form.isValid() == false) {
            return;
        }
        if ('01' == jineng.getValue() && certName.getValue() == '') {
            mini.alert("请输入证书名称");
            return;
        }
        var data = form.getData();
        var json = mini.encode(data);
        $.ajax({
            url: "/azbj/yazgl/xxbl/zyjn/save",
            data: {data: json},
            type: "post",
            success: function (success) {
                if (success.code == 1) {
                    mini.alert("保存成功", "信息提示", function () {
                        onCancel();
                    });
                } else {
                    mini.alert("保存失败");
                }
            }
        });
    }

    //切换教育类型
    function onZyjnChanged(e) {
        var id = mini.get("type").getValue();
        mini.get("zyjn").setValue("");
        var url = "/search/code/native?1=1&codeType=4_1&pcodeId=" + id;
        mini.get("zyjn").setUrl(url);
        mini.get("zyjn").select(0);
        if (mini.get("zyjn").getValue() == "") {
            var url = "/search/code/bycodeid?1=1&codeType=4_1&codeid=" + id;
            mini.get("zyjn").setUrl(url);
            mini.get("zyjn").select(0);
        }
        $("#zyid").css("display", "none");
        if (id == '-1') {
            $("#zyid").css("display", "table-row");
            mini.get("zyjn").setValue("");
        }
    }

    function onZyjnChanged1(e) {
        var id = mini.get("parentZy").getValue();
        mini.get("zyjn").setValue("");
        var url = "/search/code/native?1=1&codeType=4_1&pcodeId=" + id;
        mini.get("zyjn").setUrl(url);
        mini.get("zyjn").select(0);
        if (mini.get("zyjn").getValue() == "") {
            var url = "/search/code/bycodeid?1=1&codeType=4_1&codeid=" + id;
            mini.get("zyjn").setUrl(url);
            mini.get("zyjn").select(0);
        }
    }

    onZyjnedit1();
    onZyjnedit2();

    function onZyjnedit1() {
        var id = mini.get("type").getValue();
        if (id == 1) {
            var url = "/search/code/native?1=1&codeType=4_1&pcodeId=" + id;
            mini.get("zyjn").setUrl(url);
        }
    }

    function onZyjnedit2() {
        var id = mini.get("type").getValue();
        if (id == '02') {
            var url = "/search/code/native?1=1&codeType=4_1&pcodeId=" + id;
            mini.get("zyjn").setUrl(url);
        }
    }

    function valueChangeDo() {
        var jineng = mini.get("jineng").getValue();
        //是否获取证书:02:否 01:是
        if ('01' == jineng) {
            certName.readOnly = false;
            document.getElementById("certstyle").style.display = '';
        } else {
            mini.get("certName").setValue('');
            certName.readOnly = true;
            document.getElementById("certstyle").style.display = "none";
        }
    }
</script>
</body>
</html>